{% extends base.html %}

{% block body %}

<!-- TODO d3.js 展示内存和CPU日志 -->

<div class="col-md-12 grid-card">
    {% import web %}
    {% set title = "系统设置" %}
    {% include "tools/base_title.html" %}

    <table class="table">
        {% for item in item_list %}
            <tr>
                <td>{{item.key}}</td>
                <td>{{item.value}}</td>
            </tr>
        {% end %}
        <tr>
            <td>系统启动时间</td>
            <td>{{start_time}}</td>
        </tr>
        <tr>
            <td>系统内存占用</td>
            <td>{{sys_mem_used}} / {{sys_mem_total}}</td>
        </tr>
        <tr>
            <td>OS版本</td>
            <td>{{sys_version}}</td>
        </tr>
        <tr>
            <td>处理器</td>
            <td>{{processor}}</td>
        </tr>
        <tr>
            <td>Python版本</td>
            <td>{{python_version}}</td>
        </tr>
        <tr>
            <td>线程总数</td>
            <td>
                <span>{{thread_cnt}}</span>
                <a href="/system/thread_info">详情</a>
            </td>
        </tr>

        <!-- 主题设置 -->
        <tr class="hide">
            <td>母板类型</td>
            <td>
                <input type="radio" name="BASE_TEMPLATE" default-value="{{xconfig.BASE_TEMPLATE}}" value="base.html">base.html
                <input type="radio" name="BASE_TEMPLATE" default-value="{{xconfig.BASE_TEMPLATE}}" value="base2.html">base2.html
            </td>
        </tr>
        <tr>
            <td>主题</td>
            <td>
                <input type="radio" name="THEME" default-value="{{xconfig.THEME}}" value="standard">默认
                <input type="radio" name="THEME" default-value="{{xconfig.THEME}}" value="card">卡片
            </td>
        </tr>
        <tr>
            <td>选项风格</td>
            <td>
                <input type="radio" name="OPTION_STYLE" default-value="{{xconfig.OPTION_STYLE}}" value="aside">侧边
                <input type="radio" name="OPTION_STYLE" default-value="{{xconfig.OPTION_STYLE}}" value="top">顶部
            </td>
        </tr>
        <tr>
            <td>页面打开</td>
            <td>
                <input type="radio" name="PAGE_OPEN" default-value="{{xconfig.PAGE_OPEN}}" value="self">当前页面
                <input type="radio" name="PAGE_OPEN" default-value="{{xconfig.PAGE_OPEN}}" value="dialog">弹层
            </td>
        </tr>

        <tr>
            <td>{{T('Language')}}</td>
            <td>
                <input type="radio" name="LANG" default-value="{{web.cookies().get('lang', 'zh')}}" value="zh">中文
                <input type="radio" name="LANG" default-value="{{web.cookies().get('lang', 'zh')}}" value="en">English
            </td>
        </tr>
        <tr>
            <td>系统文件</td>
            <td>
                <input type="radio" name="FS_HIDE_FILES" default-value="{{xconfig.FS_HIDE_FILES}}" value="True">隐藏
                <input type="radio" name="FS_HIDE_FILES" default-value="{{xconfig.FS_HIDE_FILES}}" value="False">显示
            </td>
        </tr>
        <tr>
            <td>调试模式</td>
            <td>
                <input type="radio" name="DEBUG" default-value="{{xconfig.DEBUG}}" value="True">开启
                <input type="radio" name="DEBUG" default-value="{{xconfig.DEBUG}}" value="False">关闭
            </td>
        </tr>
        <tr>
            <td>开发模式</td>
            <td>
                <input type="radio" name="DEV_MODE" default-value="{{xconfig.DEV_MODE}}" value="True">开启
                <input type="radio" name="DEV_MODE" default-value="{{xconfig.DEV_MODE}}" value="False">关闭
            </td>
        </tr>
        <!--
        <tr>
            <td>文件浏览器</td>
            <td>
                <input type="radio" name="FS_LINK" default-value="{{xconfig.FS_LINK}}" value="/fs_list">列表模式
                <input type="radio" name="FS_LINK" default-value="{{xconfig.FS_LINK}}" value="/fs_sidebar">侧边栏
            </td>
        </tr>
        -->
    </table>
</div>

<script type="text/javascript">
    $("[type=radio]").on("change", function (e) {
        var val = $(e.target).val();
        var key = $(e.target).attr("name");
        // alert(val);
        $.post("/system/xconfig", 
            {key: key, value: val}, 
            function (data) {
                window.location.reload();
        })
    })
</script>

{% end %}